package com.fc.enums;

import lombok.Getter;
/**
 * 脱敏类型枚举
 */
@Getter
public enum DesensitizeType {

    NAME(0, "中文姓名"),
    ID_CARD(1, "身份证号"),
    EMAIL(2, "邮箱"),
    PHONE(3, "手机号"),
    CUSTOM(4, "自定义");

    private final int code;
    private final String description;

    DesensitizeType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 通过 code 反查枚举
     */
    public static DesensitizeType fromCode(int code) {
        for (DesensitizeType type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的脱敏类型 code: " + code);
    }
}


